import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;


public class PicButton extends JButton implements Serializable{
	
	private transient BufferedImage icon;
	private String url;
	
	public PicButton(URL url) throws IOException {
		this.setUrl(url.toString());
		icon = ImageIO.read(url);
		ImageIcon image = new ImageIcon(icon);
		setIcon(image);
	}
	
	public void changeImage(URL url) throws IOException{
		this.setUrl(url.toString());
		icon = ImageIO.read(url);
		ImageIcon image = new ImageIcon(icon);
		setIcon(image);
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

}
